﻿using System;
using System.Collections;
using System.Collections.Generic;

using Bootstrap5.Abstractions;
using Microsoft.AspNetCore.Components;

namespace Bootstrap5;

partial class Tab
{
    [Parameter][CssClass("nav-")] public NavType Type { get; set; } = NavType.Tab;
    [Parameter]  public bool Fill { get; set; }
    [Parameter]  public bool Justified { get; set; }

    [Parameter] public bool CardHeader { get; set; }

    internal IList<TabItem> Items { get; set; } = new List<TabItem>();


    internal void AddItem(TabItem item)
    {
        if (item is null)
        {
            throw new ArgumentNullException(nameof(item));
        }
        Items.Add(item);
        StateHasChanged();
    }

    ToggleName GetToggle()
    {
        if (Type== NavType.Pill)
        {
            return Bootstrap5.ToggleName.Pill;
        }
        return Bootstrap5.ToggleName.Tab;
    }

    protected override void CreateCssClass(ICssClassBuilder builder)
    {
        builder.Add($"card-header-{Type.GetEnumCssClass()}", CardHeader);
    }
}
